<!doctype html>



  


<html class="theme-next muse use-motion">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>



<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />












  
  
  <link href="/vendors/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  
    
      
    

    
  

  

  
    
      
    

    
  

  
    
      
    

    
  

  
    
    
    <link href="ajax.useso.com/css?family=Monda:300,300italic,400,400italic,700,700italic|Roboto Slab:300,300italic,400,400italic,700,700italic|Lobster Two:300,300italic,400,400italic,700,700italic|PT Mono:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/vendors/font-awesome/css/font-awesome.min.css?v=4.4.0" rel="stylesheet" type="text/css" />

<link href="/css/main.css?v=5.0.1" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="phonegap,html5," />





  <link rel="alternate" href="/atom.xml" title="葉の象牙塔" type="application/atom+xml" />




  <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico?v=5.0.1" />






<meta name="description" content="前言许久没在论坛发帖了,突然发现论坛的人气高了很多啊.以前每次签到都能前几名的现在都抢不到了.2333….,姑且不说题外话了.最近在论坛上看到两篇跨平台开发的帖子,让我颇感兴趣,但奈何竟然是mac的,这让我就很尴尬了.怎么办呢?想玩一下,奈何自己不是土豪玩家.只有平民装win7系统在手.于是我便在网上百度了一下资料,跨平台开发.这一看发现东西还真的是挺多的.只怪自己知道的太少.现在就给大家介绍一下">
<meta property="og:type" content="article">
<meta property="og:title" content="谈谈自己对跨平台开发之phonegap的理解">
<meta property="og:url" content="https://troyirvo.github.io/2016/07/23/谈谈自己对跨平台开发之phonegap的理解/index.html">
<meta property="og:site_name" content="葉の象牙塔">
<meta property="og:description" content="前言许久没在论坛发帖了,突然发现论坛的人气高了很多啊.以前每次签到都能前几名的现在都抢不到了.2333….,姑且不说题外话了.最近在论坛上看到两篇跨平台开发的帖子,让我颇感兴趣,但奈何竟然是mac的,这让我就很尴尬了.怎么办呢?想玩一下,奈何自己不是土豪玩家.只有平民装win7系统在手.于是我便在网上百度了一下资料,跨平台开发.这一看发现东西还真的是挺多的.只怪自己知道的太少.现在就给大家介绍一下">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160713/1468388125388318.bmp">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160713/1468390553117756.bmp">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468472838101460.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468473272566986.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468473325117493.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468473524732056.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468473922767342.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468474110282761.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468474193564490.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468474910100053.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468475142260944.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468475350131401.png">
<meta property="og:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468475387974368.png">
<meta property="og:updated_time" content="2016-08-14T23:36:40.041Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="谈谈自己对跨平台开发之phonegap的理解">
<meta name="twitter:description" content="前言许久没在论坛发帖了,突然发现论坛的人气高了很多啊.以前每次签到都能前几名的现在都抢不到了.2333….,姑且不说题外话了.最近在论坛上看到两篇跨平台开发的帖子,让我颇感兴趣,但奈何竟然是mac的,这让我就很尴尬了.怎么办呢?想玩一下,奈何自己不是土豪玩家.只有平民装win7系统在手.于是我便在网上百度了一下资料,跨平台开发.这一看发现东西还真的是挺多的.只怪自己知道的太少.现在就给大家介绍一下">
<meta name="twitter:image" content="http://bbs.520it.com/ueditor/php/upload/image/20160713/1468388125388318.bmp">



<script type="text/javascript" id="hexo.configuration">
  var NexT = window.NexT || {};
  var CONFIG = {
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post"},
    fancybox: true,
    motion: true,
    duoshuo: {
      userId: 6307471233734673000,
      author: '博主大人'
    }
  };
</script>




  <link rel="canonical" href="https://troyirvo.github.io/2016/07/23/谈谈自己对跨平台开发之phonegap的理解/"/>

  <title> 谈谈自己对跨平台开发之phonegap的理解 | 葉の象牙塔 </title>
</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  


<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
          m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
  ga('create', 'UA-80976022-1', 'auto');
  ga('send', 'pageview');
</script>


  <script type="text/javascript">
    var _hmt = _hmt || [];
    (function() {
      var hm = document.createElement("script");
      hm.src = "//hm.baidu.com/hm.js?fa72623847605eda2379b9be6d8f9f19";
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(hm, s);
    })();
  </script>








  
  
    
  

  <div class="container one-collumn sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-meta ">
  

  <div class="custom-logo-site-title">
    <a href="/"  class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <span class="site-title">葉の象牙塔</span>
      <span class="logo-line-after"><i></i></span>
    </a>
  </div>
  <p class="site-subtitle">葉の轩, 一个小屋, 住下自己内心最真实的自己!</p>
</div>

<div class="site-nav-toggle">
  <button>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
    <span class="btn-bar"></span>
  </button>
</div>
<a href="https://github.com/TroyIrvo">
<img style="position: absolute; top: 0; left: 0; border: 0;" src="https://camo.githubusercontent.com/121cd7cbdc3e4855075ea8b558508b91ac463ac2/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f6c6566745f677265656e5f3030373230302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_left_green_007200.png"></a>
<center><iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=100 height=110 src="http://music.163.com/outchain/player?type=0&id=427819309&auto=0&height=90"></iframe></center>

<!--<script type="text/javascript">(function(){document.write(unescape('%3Cdiv id="bdcs"%3E%3C/div%3E'));var bdcs = document.createElement('script');bdcs.type = 'text/javascript';bdcs.async = true;bdcs.src = 'http://znsv.baidu.com/customer_search/api/js?sid=8555499146671547623' + '&plate_url=' + encodeURIComponent(window.location.href) + '&t=' + Math.ceil(new Date()/3600000);var s = document.getElementsByTagName('script')[0];s.parentNode.insertBefore(bdcs, s);})();</script>-->
<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/archives" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/tags" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-guestbook">
          <a href="/guestbook" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            留言
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/404.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
        <li class="menu-item menu-item-search">
          
            <a href="javascript:;" class="popup-trigger">
          
            
              <i class="menu-item-icon fa fa-search fa-fw"></i> <br />
            
            搜索
          </a>
        </li>
      
    </ul>
  

  
    <div class="site-search">
      
  <div class="popup">
 <span class="search-icon fa fa-search"></span>
 <input type="text" id="local-search-input">
 <div id="local-search-result"></div>
 <span class="popup-btn-close">close</span>
</div>


    </div>
  
</nav>

 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  
  

  
  
  

  <article class="post post-type-normal " itemscope itemtype="http://schema.org/Article">

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
            
            
              
                谈谈自己对跨平台开发之phonegap的理解
              
            
          </h1>
        

        <div class="post-meta">
          <span class="post-time">
            <span class="post-meta-item-icon">
              <i class="fa fa-calendar-o"></i>
            </span>
            <span class="post-meta-item-text">发表于</span>
            <time itemprop="dateCreated" datetime="2016-07-23T17:13:24+08:00" content="2016-07-23">
              2016-07-23
            </time>
          </span>

          
            <span class="post-category" >
              &nbsp; | &nbsp;
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="https://schema.org/Thing">
                  <a href="/categories/跨平台/" itemprop="url" rel="index">
                    <span itemprop="name">跨平台</span>
                  </a>
                </span>

                
                

              
            </span>
          

          
            
              <span class="post-comments-count">
                &nbsp; | &nbsp;
                <a href="/2016/07/23/谈谈自己对跨平台开发之phonegap的理解/#comments" itemprop="discussionUrl">
                  <span class="post-comments-count ds-thread-count" data-thread-key="2016/07/23/谈谈自己对跨平台开发之phonegap的理解/" itemprop="commentsCount"></span>
                </a>
              </span>
            
          

          

          
          
             <span id="/2016/07/23/谈谈自己对跨平台开发之phonegap的理解/" class="leancloud_visitors" data-flag-title="谈谈自己对跨平台开发之phonegap的理解">
               &nbsp; | &nbsp;
               <span class="post-meta-item-icon">
                 <i class="fa fa-eye"></i>
               </span>
               <span class="post-meta-item-text">阅读次数 </span>
               <span class="leancloud-visitors-count"></span>
              </span>
          

          
        </div>
      </header>
    


    <div class="post-body" itemprop="articleBody">

      
      

      
        <h2 id="前言"><a href="#前言" class="headerlink" title="前言"></a>前言</h2><p>许久没在论坛发帖了,突然发现论坛的人气高了很多啊.以前每次签到都能前几名的现在都抢不到了.2333….,姑且不说题外话了.最近在论坛上看到两篇跨平台开发的帖子,让我颇感兴趣,但奈何竟然是mac的,这让我就很尴尬了.怎么办呢?想玩一下,奈何自己不是土豪玩家.只有平民装win7系统在手.于是我便在网上百度了一下资料,跨平台开发.这一看发现东西还真的是挺多的.只怪自己知道的太少.现在就给大家介绍一下我研究的phonegap吧!<a id="more"></a>之所以拿这个phonegap技术来说明主要是因为这种跨平台开发已经在网上有很多学习资料可方便大家要是感兴趣可以自己进一步去了解.本篇只为帮你打开一扇窗口.</p>
<p>说了这么多可能很多人还不清楚什么是phonegap.以下是我在百度的一些资料（请相信百度还是专业的）。<br><img src="http://bbs.520it.com/ueditor/php/upload/image/20160713/1468388125388318.bmp" alt="什么是phonegap"></p>
<pre><code>看完这个介绍。是否让你觉得这个东西还是挺有意思的呢？
再来看看他支持的手机操作系统。
</code></pre><p><img src="http://bbs.520it.com/ueditor/php/upload/image/20160713/1468390553117756.bmp" alt="phonegap支持的系统"><br> 此时你是否感觉这个phonegap很牛逼！！！竟然写一套代码就能支持这么多的系统。然后你再看看它需要用到的开发技术。卧槽！！竟然是html+js+css，做我们这一行的应该都清楚这三剑客吧！我一直觉得这个phonegap出现的意义就在于它让web前端开发人员一样拥有了和android/ios开发人员开发移动应用程序的能力。你想想，web前端开发人员可以使用他们熟悉的前端技术就可以在该平台上进行移动开发。相比之下，我们android/ios必须要去学习java，oc/swift等等。若此时一个从事多年web开发的人员想做一个app。他再也不用去做这些知识储备了。直接利用phonegap进行开发。简直是web前端人员的福音啊！</p>
<p>  PhoneGap是一套能让你使用HTML5轻松调用本地API接口和发布应用到商店的应用开发平台。官方说有低成本，低开发周期，轻量化等优点，这些咱 暂时也没法证明，略过不表。但是有一条跨平台，却是很明显的优势。因为它采用HTML5+JavaScript的模式来开发应用 .PhoneGap后来被Adobe收购，然后又贡献给了开源社区，现在由Apache管理，改名cordova。</p>
<p>   说了这么多，还不如亲自实践一番。下面我们就来尝试如何在winxp/win7使用phonegap搭建一个跨平台的app应用。</p>
<p>   (注:win8和win10没有尝试过,有兴趣的可以自行查询资料)</p>
<h2 id="一、环境准备"><a href="#一、环境准备" class="headerlink" title="一、环境准备"></a>一、环境准备</h2><p> 1.1、安装node.js </p>
<p>  下载链接：</p>
<p>这是因为安装cordova时要用到node.js的npm ,<a href="http://nodejs.org/" target="_blank" rel="external">下载连接</a><br>   下载安装成功之后,打开cmd,进入D盘,创建cordova的工作空间: cordovaspace</p>
<p>  成功标志：</p>
<p>   测试安装结果命令: node -v<br><img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468472838101460.png" alt="成功截图"></p>
<p>1.2、安装git(主要是为了下载一些需要使用的插件)</p>
<p>   下载链接：用于后面有些插件可能需要用git来下载, </p>
<p>   <a href="http://git-scm.com/" target="_blank" rel="external">下载链接</a></p>
<p>   <a href="http://jingyan.baidu.com/article/90895e0fb3495f64ed6b0b50.html" target="_blank" rel="external">指导链接</a></p>
<p>  成功标志：</p>
<p>   安装完成后，在开始菜单里找到“Git”-&gt;“Git Bash”，蹦出一个类似命令行窗口的东西，就说明Git安装成功<br>   <img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468473272566986.png" alt=""> </p>
<p>1.3、安装ant(注：如果不安装的话后台的操作会报找不到ant; )</p>
<p>   <a href="http://apache.dataguru.cn//ant/binaries/apache-ant-1.9.4-bin.zip" target="_blank" rel="external">下载连接</a></p>
<p>   <a href="http://www.cnblogs.com/yuzhongwusan/archive/2013/03/26/2982411.html" target="_blank" rel="external">指导链接</a></p>
<p>   下载好之后,解压出来,我这里解压到D:\Delp_Tool\ant-1.8.2下,<br>   然后在环境变量中配置变量ANT_HOME,值:D:\Delp_Tool\ant-1.8.2,<br>   在PATH中追加%ANT_HOME%\bin;</p>
<p>   成功标志：</p>
<p>   测试安装效果命令: ant -v</p>
<p>  <img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468473325117493.png" alt=""></p>
<p>二、安装cordova CLI</p>
<p>2.1、安装命令：</p>
<pre><code>npm install -g cordova
</code></pre><p>如果出现如下错误(如未发生此错误请自动忽略):</p>
<p>  <img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468473524732056.png" alt=""></p>
<p>   原因: 代理问题.(如果你在公司一般要设置公司外网地址)  </p>
<p>   设置代理：</p>
<p>   npm config set proxy=<a href="http://192.168.xx.xxx:80" target="_blank" rel="external">http://192.168.xx.xxx:80</a>   （这是你公司的代理）</p>
<p>   当需要制定安装版本时，请加版本号。</p>
<pre><code>npm install -g cordova@xxx
</code></pre><p>   xxx：对应的版本号</p>
<p>   因为不同的cordova 对应不同的android的sdk版本 ! 因为不同的cordova 对应不同的android的sdk版本!因为不同的cordova 对应不同的android 的sdk版本! 重要的话说三遍!!! 我在这里栽倒过很多次….</p>
<p>   2.2、测试安装结果命令：cordova -v</p>
<p>   <img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468473922767342.png" alt=""></p>
<p>三、创建app</p>
<p>这里创建一个命名为firstApp，id为com.cycle.first的app，放在first文件夹下:<br>   创建命令：</p>
<pre><code>cordova  -d create first com.cycle.firstApp firstApp
</code></pre><p>   <img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468474110282761.png" alt=""></p>
<p>   创建过程需要下载一些cordova的库，所以得等一下，上面命令中的-d是展示创建过程中的一些细节命令执行完后会得到这么一个目录结构的<br><img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468474193564490.png" alt=""></p>
<p>./first</p>
<p>./first/config.xml</p>
<p>./first/hooks</p>
<p>./first/hooks/README.md</p>
<p>./first/platforms</p>
<p>./first/plugin</p>
<p>./first/www</p>
<p>./first/www/css</p>
<p>./first/www/img</p>
<p>./first/www/js</p>
<p>./first/www/index.html</p>
<p>注:这个目录结构感兴趣的可以自行研究各自代表什么意思.</p>
<p>四、添加平台(注：添加平台前必须得先安装该平台的sdk)<br>这一步没做好，可能导致不能打包<br>4.1、安装sdk</p>
<p>注意：上面说到cordova版本要和sdk一致.那么安卓sdk和cordavo版本之间有这么个关系大致我测试的结果是:</p>
<pre><code>3.0需要的是android-17（Android 4.2.2）
3.1和3.2需要android-18（Android 4.3）
3.3、3.4、3.5需要android-19（Android 4.4.2）（同时ant1.8+）
</code></pre><p>下载安装好adt后，还需要在环境变量中配置变量ANDROID_HOME，值得为sdk所有的目录，<br>比如我的就安装D:\androidWorkspace\adt\sdk，那就将ANDROID_HOME指向这个目录，并在PATH中<br>追加%ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools;</p>
<p>注：修改了PATH后需要重启cmd才可以生效。</p>
<p>4.2、添加平台</p>
<p>添加平台命令：</p>
<p>接下来的命令都需要在app的次级目录下执行，<br>进入</p>
<pre><code>first : cd first
</code></pre><p>添加安卓: </p>
<pre><code>cordova platform add android
</code></pre><p><img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468474910100053.png" alt=""></p>
<p>添加其他的平台:</p>
<pre><code>cordova platform add ios
cordova platform add amazon-fireos
cordova platform add blackberry10
cordova platform add firefoxos
</code></pre><p>创建完之后可以用下面这条命令来查看已添加以及可支持添加的平台：<br>    cordova platforms ls<br><img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468475142260944.png" alt=""></p>
<p>如果想删除某个平台的话，可以这样：</p>
<pre><code>cordova platform rm amazon-fireos
cordova platform remove android
</code></pre><p>添加之后会./first/platforms下的目录，增加一个相应平台的目录，而删除平台的话，也会将这个目录删除。</p>
<p>删除卸载cordova。</p>
<pre><code>npm uninstall cordova  -g
npm uninstall phonegap -g
</code></pre><p>最后去c盘（默认安装）搜索cordova 的文件夹 找到相关的干掉 就可以了</p>
<p>xp中文件夹位于：</p>
<p><img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468475350131401.png" alt=""></p>
<p>win7文件夹位于：</p>
<p><img src="http://bbs.520it.com/ueditor/php/upload/image/20160714/1468475387974368.png" alt=""></p>
<p>五、编译运行 app</p>
<p>cordova build<br>这条命令将编译./firstApp/platforms下所有的平台，如果只想单独编译其中的平台的话，只需要在build上增加该平台名即可。<br>cordova build android</p>
<p>貌似头一回编译时都比较慢。。。<br>编译的过程中，会输出一堆东西。。最后如果看到build successful,就可以了。<br>实际上，build命令是prepare 以及compile两条命令的缩写。上面这条命令相当于：</p>
<pre><code>cordova prepare android
cordova compile android
</code></pre><p><a href="http://jingyan.baidu.com/article/86fae346d09d093c49121a05.html" target="_blank" rel="external">这里给一个链接</a></p>
<p>六、总结</p>
<p>   本文只是初略的讲了一下如何简单实用phonegap.,但其实还有很多东西由于笔者自身知识的局限性没有提及.像添加插件.自定义插件等等.</p>
<p>本人能力有限,觉得自己讲不清楚.但网上有一些资料.如果你想了解更多.可以看看网上大神的教程.顺便提一下,现在比较流行的跨平台开发框架有很多,比如像ionic+angular.js+phonegap.有兴趣的也可以好好的去研究一下啦!毕竟知道的越多,以后去面试也能装装逼!!!</p>
<p>附上<a href="http://phonegap.com/getstarted/" target="_blank" rel="external">官网链接:</a> 看官网介绍貌似现在可以下载客户端不需要通过命令行的方式来创建phonegap项目了.</p>
<p>附上本人:<a href="http://note.youdao.com/yws/public/redirect/share?id=2b989375cf4802bddaaa4330d4568f37&amp;type=false" target="_blank" rel="external">笔记地址</a></p>
<p>附上:<br><a href="http://plugins.cordova.io/" target="_blank" rel="external">插件</a><br>   <a href="http://t.cn/RLcANQd" target="_blank" rel="external">文档</a><br>   <a href="http://t.cn/RLcAj1o" target="_blank" rel="external">SDK</a><br>   <a href="http://t.cn/RLcq8rW" target="_blank" rel="external">调试教程</a></p>
<p>   以上,就是笔者对phonegap的一些研究.可能并不是那么的全面.甚至可能有错误的理解.还望大家积极交流指正!</p>

      
    </div>

    <div>
      
        

      
    </div>

    <div>
      
        
  <div style="padding: 10px 0; margin: 20px auto; width: 90%; text-align: center;">
    <div>坚持原创技术分享，您的支持将鼓励我继续创作！</div>
    <button id="rewardButton" disable="enable" onclick="var qr = document.getElementById('QR'); if (qr.style.display === 'none') {qr.style.display='block';} else {qr.style.display='none'}">
      <span>赏</span>
    </button>
    <div id="QR" style="display: none;">
      
        <div id="wechat" style="display: inline-block">
          <img id="wechat_qr" src="/images/wechatpay.jpg" alt="TroyIrvo 葉十二 WeChat Pay"/>
          <p>微信打赏</p>
        </div>
      
      
        <div id="alipay" style="display: inline-block">
          <img id="alipay_qr" src="/images/alipay.jpg" alt="TroyIrvo 葉十二 Alipay"/>
          <p>支付宝打赏</p>
        </div>
      
    </div>
  </div>


      
    </div>

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/tags/phonegap/" rel="tag">#phonegap</a>
          
            <a href="/tags/html5/" rel="tag">#html5</a>
          
        </div>
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/2016/07/22/基于github-hexo-next搭建博客/" rel="next" title="基于github+hexo+next搭建博客">
                <i class="fa fa-chevron-left"></i> 基于github+hexo+next搭建博客
              </a>
            
          </div>

          <div class="post-nav-prev post-nav-item">
            
              <a href="/2016/08/09/android复习笔记-1/" rel="prev" title="android复习笔记(1)">
                android复习笔记(1) <i class="fa fa-chevron-right"></i>
              </a>
            
          </div>
        </div>
      

      
      
    </footer>
  </article>



    <div class="post-spread">
      
        <!-- JiaThis Button BEGIN -->
<div class="jiathis_style">
  <a class="jiathis_button_tsina"></a>
  <a class="jiathis_button_tqq"></a>
  <a class="jiathis_button_weixin"></a>
  <a class="jiathis_button_cqq"></a>
  <a class="jiathis_button_douban"></a>
  <a class="jiathis_button_renren"></a>
  <a class="jiathis_button_qzone"></a>
  <a class="jiathis_button_kaixin001"></a>
  <a class="jiathis_button_copy"></a>
  <a href="http://www.jiathis.com/share" class="jiathis jiathis_txt jiathis_separator jtico jtico_jiathis" target="_blank"></a>
  <a class="jiathis_counter_style"></a>
</div>
<script type="text/javascript" >
  var jiathis_config={
    hideMore:false
  }
</script>
<script type="text/javascript" src="http://v3.jiathis.com/code/jia.js" charset="utf-8"></script>
<!-- JiaThis Button END -->

      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
      <div class="ds-thread" data-thread-key="2016/07/23/谈谈自己对跨平台开发之phonegap的理解/"
           data-title="谈谈自己对跨平台开发之phonegap的理解" data-url="https://troyirvo.github.io/2016/07/23/谈谈自己对跨平台开发之phonegap的理解/">
      </div>
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel ">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="http://oaf5v9at6.bkt.clouddn.com/%E5%89%8D%E5%89%8D%E4%B8%96%E4%B8%96.jpg"
               alt="TroyIrvo 葉十二" />
          <p class="site-author-name" itemprop="name">TroyIrvo 葉十二</p>
          <p class="site-description motion-element" itemprop="description">将来的你一定会感谢现在如此拼命的自己!!!</p>
        </div>
        <nav class="site-state motion-element">
          <div class="site-state-item site-state-posts">
            <a href="/archives">
              <span class="site-state-item-count">6</span>
              <span class="site-state-item-name">日志</span>
            </a>
          </div>

          
            <div class="site-state-item site-state-categories">
              <a href="/categories">
                <span class="site-state-item-count">5</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            <div class="site-state-item site-state-tags">
              <a href="/tags">
                <span class="site-state-item-count">9</span>
                <span class="site-state-item-name">标签</span>
              </a>
            </div>
          

        </nav>

        
          <div class="feed-link motion-element">
            <a href="/atom.xml" rel="alternate">
              <i class="fa fa-rss"></i>
              RSS
            </a>
          </div>
        

        <div class="links-of-author motion-element">
          
            
              <span class="links-of-author-item">
                <a href="https://github.com/TroyIrvo" target="_blank" title="GitHub">
                  
                    <i class="fa fa-fw fa-github"></i>
                  
                  GitHub
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://twitter.com/TroyDhc" target="_blank" title="Twitter">
                  
                    <i class="fa fa-fw fa-twitter"></i>
                  
                  Twitter
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="http://weibo.com/TroyIrvo" target="_blank" title="微博">
                  
                    <i class="fa fa-fw fa-globe"></i>
                  
                  微博
                </a>
              </span>
            
              <span class="links-of-author-item">
                <a href="https://www.facebook.com/TroyIrvo" target="_blank" title="Facebook">
                  
                    <i class="fa fa-fw fa-facebook"></i>
                  
                  Facebook
                </a>
              </span>
            
          
        </div>

        
        

        
        
          <div class="links-of-blogroll motion-element links-of-blogroll-inline">
            <div class="links-of-blogroll-title">
              <i class="fa  fa-fw fa-globe"></i>
              Links
            </div>
            <ul class="links-of-blogroll-list">
              
                <li class="links-of-blogroll-item">
                  <a href="https://mapledev.github.io/" title="Mr.Zhou" target="_blank" rel="external nofollow">Mr.Zhou</a>
                </li>
              
            </ul>
          </div>
        

      </section>

      
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">
            
              
            
            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#前言"><span class="nav-number">1.</span> <span class="nav-text">前言</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#一、环境准备"><span class="nav-number">2.</span> <span class="nav-text">一、环境准备</span></a></li></ol></div>
            
          </div>
        </section>
      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy;  2016 - 
  <span itemprop="copyrightYear">2017</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">TroyIrvo 葉十二</span>
</div>
<script type="text/javascript">
(function(){
    var bp = document.createElement('script');
    var curProtocol = window.location.protocol.split(':')[0];
    if (curProtocol === 'https') {
        bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';        
    }
    else {
        bp.src = 'http://push.zhanzhang.baidu.com/push.js';
    }
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(bp, s);
})();
</script>
<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io" rel="external nofollow">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next" rel="external nofollow">
    NexT.Muse
  </a>
</div>

        

<div class="busuanzi-count">

  <script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js"></script>

  
    <span class="site-uv"><i class="fa fa-user">本站访客数</i><span class="busuanzi-value" id="busuanzi_value_site_uv"></span>人次</span>
  

  
    <span class="site-pv"><i class="fa fa-eye">本站总访问量</i><span class="busuanzi-value" id="busuanzi_value_site_pv"></span>次</span>
  
  
</div>



        
      </div>
    </footer>

    <div class="back-to-top">
      <i class="fa fa-arrow-up"></i>
    </div>
  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  



  
  <script type="text/javascript" src="/vendors/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/vendors/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/vendors/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/vendors/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/js/src/utils.js?v=5.0.1"></script>

  <script type="text/javascript" src="/js/src/motion.js?v=5.0.1"></script>



  
  

  
  <script type="text/javascript" src="/js/src/scrollspy.js?v=5.0.1"></script>
<script type="text/javascript" src="/js/src/post-details.js?v=5.0.1"></script>



  


  <script type="text/javascript" src="/js/src/bootstrap.js?v=5.0.1"></script>



  

  
    
  

  <script type="text/javascript">
    var duoshuoQuery = {short_name:"dhctroy"};
    (function() {
      var ds = document.createElement('script');
      ds.type = 'text/javascript';ds.async = true;
      ds.id = 'duoshuo-script';
      ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
      ds.charset = 'UTF-8';
      (document.getElementsByTagName('head')[0]
      || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
  </script>

  
    
    <script src="/vendors/ua-parser-js/dist/ua-parser.min.js?v=0.7.9"></script>
    <script src="/js/src/hook-duoshuo.js"></script>
  






  
  
  <script type="text/javascript">
    // Popup Window;
    var isfetched = false;
    // Search DB path;
    var search_path = "search.xml";
    if (search_path.length == 0) {
       search_path = "search.xml";
    }
    var path = "/" + search_path;
    // monitor main search box;

    function proceedsearch() {
      $("body").append('<div class="popoverlay">').css('overflow', 'hidden');
      $('.popup').toggle();

    }
    // search function;
    var searchFunc = function(path, search_id, content_id) {
    'use strict';
    $.ajax({
        url: path,
        dataType: "xml",
        async: true,
        success: function( xmlResponse ) {
            // get the contents from search data
            isfetched = true;
            $('.popup').detach().appendTo('.header-inner');
            var datas = $( "entry", xmlResponse ).map(function() {
                return {
                    title: $( "title", this ).text(),
                    content: $("content",this).text(),
                    url: $( "url" , this).text()
                };
            }).get();
            var $input = document.getElementById(search_id);
            var $resultContent = document.getElementById(content_id);
            $input.addEventListener('input', function(){
                var matchcounts = 0;
                var str='<ul class=\"search-result-list\">';
                var keywords = this.value.trim().toLowerCase().split(/[\s\-]+/);
                $resultContent.innerHTML = "";
                if (this.value.trim().length > 1) {
                // perform local searching
                datas.forEach(function(data) {
                    var isMatch = true;
                    var content_index = [];
                    var data_title = data.title.trim().toLowerCase();
                    var data_content = data.content.trim().replace(/<[^>]+>/g,"").toLowerCase();
                    var data_url = data.url;
                    var index_title = -1;
                    var index_content = -1;
                    var first_occur = -1;
                    // only match artiles with not empty titles and contents
                    if(data_title != '' && data_content != '') {
                        keywords.forEach(function(keyword, i) {
                            index_title = data_title.indexOf(keyword);
                            index_content = data_content.indexOf(keyword);
                            if( index_title < 0 && index_content < 0 ){
                                isMatch = false;
                            } else {
                                if (index_content < 0) {
                                    index_content = 0;
                                }
                                if (i == 0) {
                                    first_occur = index_content;
                                }
                            }
                        });
                    }
                    // show search results
                    if (isMatch) {
                        matchcounts += 1;
                        str += "<li><a href='"+ data_url +"' class='search-result-title'>"+ data_title +"</a>";
                        var content = data.content.trim().replace(/<[^>]+>/g,"");
                        if (first_occur >= 0) {
                            // cut out 100 characters
                            var start = first_occur - 20;
                            var end = first_occur + 80;
                            if(start < 0){
                                start = 0;
                            }
                            if(start == 0){
                                end = 50;
                            }
                            if(end > content.length){
                                end = content.length;
                            }
                            var match_content = content.substring(start, end);
                            // highlight all keywords
                            keywords.forEach(function(keyword){
                                var regS = new RegExp(keyword, "gi");
                                match_content = match_content.replace(regS, "<b class=\"search-keyword\">"+keyword+"</b>");
                            });

                            str += "<p class=\"search-result\">" + match_content +"...</p>"
                        }
                        str += "</li>";
                    }
                })};
                str += "</ul>";
                if (matchcounts == 0) { str = '<div id="no-result"><i class="fa fa-frown-o fa-5x" /></div>' }
                if (keywords == "") { str = '<div id="no-result"><i class="fa fa-search fa-5x" /></div>' }
                $resultContent.innerHTML = str;
            });
            proceedsearch();
        }
    });}

    // handle and trigger popup window;
    $('.popup-trigger').click(function(e) {
      e.stopPropagation();
      if (isfetched == false) {
        searchFunc(path, 'local-search-input', 'local-search-result');
      } else {
        proceedsearch();
      };

    });

    $('.popup-btn-close').click(function(e){
      $('.popup').hide();
      $(".popoverlay").remove();
      $('body').css('overflow', '');
    });
    $('.popup').click(function(e){
      e.stopPropagation();
    });
  </script>


  

  

  
  <script src="https://cdn1.lncld.net/static/js/av-core-mini-0.6.1.js"></script>
  <script>AV.initialize("lC3JT90BWA1fL1nwnYTl2LDa-gzGzoHsz", "D5iE3tXLgFl3KC7FfVkKFsaF");</script>
  <script>
    function showTime(Counter) {
      var query = new AV.Query(Counter);
      var entries = [];
      var $visitors = $(".leancloud_visitors");

      $visitors.each(function () {
        entries.push( $(this).attr("id").trim() );
      });

      query.containedIn('url', entries);
      query.find()
        .done(function (results) {
          var COUNT_CONTAINER_REF = '.leancloud-visitors-count';

          if (results.length === 0) {
            $visitors.find(COUNT_CONTAINER_REF).text(0);
            return;
          }

          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.get('url');
            var time = item.get('time');
            var element = document.getElementById(url);

            $(element).find(COUNT_CONTAINER_REF).text(time);
          }
          for(var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = document.getElementById(url);
            var countSpan = $(element).find(COUNT_CONTAINER_REF);
            if( countSpan.text() == '') {
              countSpan.text(0);
            }
          }
        })
        .fail(function (object, error) {
          console.log("Error: " + error.code + " " + error.message);
        });
    }

    function addCount(Counter) {
      var $visitors = $(".leancloud_visitors");
      var url = $visitors.attr('id').trim();
      var title = $visitors.attr('data-flag-title').trim();
      var query = new AV.Query(Counter);

      query.equalTo("url", url);
      query.find({
        success: function(results) {
          if (results.length > 0) {
            var counter = results[0];
            counter.fetchWhenSave(true);
            counter.increment("time");
            counter.save(null, {
              success: function(counter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(counter.get('time'));
              },
              error: function(counter, error) {
                console.log('Failed to save Visitor num, with error message: ' + error.message);
              }
            });
          } else {
            var newcounter = new Counter();
            /* Set ACL */
            var acl = new AV.ACL();
            acl.setPublicReadAccess(true);
            acl.setPublicWriteAccess(true);
            newcounter.setACL(acl);
            /* End Set ACL */
            newcounter.set("title", title);
            newcounter.set("url", url);
            newcounter.set("time", 1);
            newcounter.save(null, {
              success: function(newcounter) {
                var $element = $(document.getElementById(url));
                $element.find('.leancloud-visitors-count').text(newcounter.get('time'));
              },
              error: function(newcounter, error) {
                console.log('Failed to create');
              }
            });
          }
        },
        error: function(error) {
          console.log('Error:' + error.code + " " + error.message);
        }
      });
    }

    $(function() {
      var Counter = AV.Object.extend("Counter");
      if ($('.leancloud_visitors').length == 1) {
        addCount(Counter);
      } else if ($('.post-title-link').length > 1) {
        showTime(Counter);
      }
    });
  </script>



  

</body>
</html>
